package com.bw.launcher

import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.BarUtils
import com.bw.baseapplication.BaseApplication
import kotlinx.coroutines.*

class SplashActivity : AppCompatActivity(){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val view = LayoutInflater.from(this).inflate(R.layout.activity_splash,null,false)
        setContentView(view)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            window.decorView.systemUiVisibility = (
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
        }
        BarUtils.addMarginTopEqualStatusBarHeight(view)
        BarUtils.setStatusBarColor(this, Color.WHITE)
        ARouter.init(BaseApplication.baseApplication)
        ARouter.openLog()
        ARouter.debuggable()
        GlobalScope.launch {
            val timmer = async { timmer() }
            timmer.await()
            startActivity(Intent(this@SplashActivity,FrameActivity::class.java))
            this@SplashActivity.finish()
        }

    }

    private suspend fun timmer(){
        delay(3*1000)
    }

}